package com.lc.tgxm.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.lc.tgxm.R;
import com.lc.tgxm.util.Log;
import com.lc.tgxm.util.Utils;
import com.zcx.helper.util.UtilToast;

/**
 * LoginActivity
 * Created by Lei on 2017/4/25.
 */
public class LoginActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initContenViewAndBack(R.layout.activity_login, R.string.login);

    }

    @Override
    public void onButtonClick(View view) {
        switch (view.getId()) {
            case R.id.btn_login:
                loginAction();
                break;
        }
    }

    // 登录动作
    public void loginAction() {
        EditText etName = (EditText) findViewById(R.id.et_name);
        EditText etpwd = (EditText) findViewById(R.id.et_pwd);
        String name = etName.getText().toString();
        String pwdstr = etpwd.getText().toString();

        // 密码最小长度
        int pwdminLength = getResources().getInteger(R.integer.password_minlength);
        if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwdstr)) {
            UtilToast.show(R.string.to_notnull);
        } else if (!Utils.checkMobile(name)) {// 手机号合法性
            UtilToast.show(R.string.to_phoneillegal);
        } else if (pwdstr.length() < pwdminLength) {
            UtilToast.show(String.format(getString(R.string.to_notminlength), pwdminLength));
        } else {
            // 执行接口
            Log.i(TAG, "Do Register conn interface", ":" + name + ":" + pwdstr);

        }
    }

}